package com.gollum.manager;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import javax.annotation.PreDestroy;

/**
 * 关闭线程池管理器
 *
 * @author Herther
 * @version 1.0.0
 * @createTime 2022年08月26日 22:43:00
 */
@Component
public class ShutdownManager {

    private static final Logger log = LoggerFactory.getLogger(ShutdownManager.class);

    @PreDestroy
    public void destroy() {
        shutdownAsyncManager();
    }

    /**
     * 停止异步执行任务
     */
    private void shutdownAsyncManager() {
        try {
            log.info("------------正在关闭线程池异步任务------------");
            AsyncManager.me().shutdown();
        }
        catch (Exception e) {
            log.error("关闭异步任务线程池失败：[{}|]",e.getMessage());
        }
    }

}
